package com.diankangwo.sys.controller;

import com.diankangwo.common.annotation.SysLog;
import com.diankangwo.common.utils.R;
import com.diankangwo.common.validator.ValidatorUtils;
import com.diankangwo.common.validator.group.AddGroup;
import com.diankangwo.common.validator.group.UpdateGroup;
import com.diankangwo.sys.entity.SysThirdPartyServiceEntity;
import com.diankangwo.sys.service.SysThirdPartyService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** 第三方短信接口
 * Created by wuye on 2017/9/11.
 */
@RestController
@RequestMapping("/sys/sms")
public class SysThirdPartyServiceController extends AbstractController{

    @Autowired
    private SysThirdPartyService sysThirdPartyService;


    /**
     * 根据ID查询第三方服务信息
     * @param id
     * @return
     */
    @ApiOperation(value = "根据ID查询第三方服务信息",notes = "")
    @ApiImplicitParam(name = "id",value = "第三方短信接口信息ID",required = true,dataType = "int")
    @SysLog("根据ID查询")
    @RequestMapping("/info")
    @RequiresPermissions("sys:sms:info")
    public R queryById(@PathVariable("id") int id){

        return R.ok();
    }



    /**
     * 保存第三方接口
     */
    @ApiOperation(value = "保存第三方接口",notes = "")
    @ApiImplicitParam(name = "sysThirdPartyServiceEntity",value = "保存第三方接口",required = true,dataType = "SysThirdPartyServiceEntity")
    @SysLog("保存第三方接口")
    @RequestMapping("/save")
    @RequiresPermissions("sys:sms:save")
    public R save(@RequestBody SysThirdPartyServiceEntity sysThirdPartyServiceEntity){
        ValidatorUtils.validateEntity(sysThirdPartyServiceEntity, AddGroup.class);
        sysThirdPartyService.save(sysThirdPartyServiceEntity);
        return R.ok();
    }




    /**
     * 修改第三方接口
     */
    @ApiOperation(value = "修改第三方接口",notes = "")
    @ApiImplicitParam(name = "sysThirdPartyServiceEntity",value = "修改第三方接口",required = true,dataType = "SysUserEntity")
    @SysLog("修改用户")
    @RequestMapping("/update")
    @RequiresPermissions("sys:sms:update")
    public R update(@RequestBody SysThirdPartyServiceEntity sysThirdPartyServiceEntity){
        ValidatorUtils.validateEntity(sysThirdPartyServiceEntity, UpdateGroup.class);
        sysThirdPartyService.update(sysThirdPartyServiceEntity);
        return R.ok();
    }
}
